import Vue from 'vue'
import Vuex from 'vuex'
import {getItem,setItem} from '@/utils/storage.js'

Vue.use(Vuex)

const USER_TOKEN = "TOUTIAO_USER"

export default new Vuex.Store({
  state: {
    user:getItem(USER_TOKEN)
  },
  mutations: {
    setUser(state,userInfo){
      // vuex中设置token
      state.user = userInfo
      // 本地存储设置token
      // localStorage.setItem(USER_TOKEN,JSON.stringify(userInfo))
      setItem(USER_TOKEN,userInfo)
    }
  },
  actions: {
  },
  modules: {
  }
})
